package com.source.hotelbath.base;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.ViewUtils;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.Window;

import static android.icu.lang.UCharacter.GraphemeClusterBreak.L;

/**
 * Created by ZhouMeng on 2017/9/23.
 */

public abstract class BaseFragmentActivity extends FragmentActivity implements View.OnClickListener {
    protected GestureDetector mGestureDetector;

    public BaseFragmentActivity() {
    }

    protected void onCreate(Bundle var1) {
        super.onCreate(var1);
        doBeforeSetcontentView();
        if (this.beforeCreate(var1)) {
            this.onBaseCreate(var1);
            this.bindView(var1);
            this.afterCreate();
        }

    }

    /**
     * 设置layout前配置
     */
    private void doBeforeSetcontentView() {
        // 把actvity放到application栈中管理
        AppManager.getAppManager().addActivity(this);
        // 无标题
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        // 设置竖屏
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    }

    protected boolean beforeCreate(Bundle var1) {
        return true;
    }

    protected abstract void onBaseCreate(Bundle var1);

    protected abstract void bindView(Bundle var1);

    protected void afterCreate() {
    }

    public void setContentView(int var1) {
        super.setContentView(var1);

    }

    public void onClick(View var1) {
    }



    public boolean dispatchTouchEvent(MotionEvent var1) {
        if (null != this.mGestureDetector) {
            this.mGestureDetector.onTouchEvent(var1);
        }

        return super.dispatchTouchEvent(var1);
    }

    protected void onDestroy() {
        super.onDestroy();
        AppManager.getAppManager().finishActivity(this);
    }
}

